﻿using System;

namespace Bubble
{
    class Player
    {
        private static int[] levels = new int[] { 20, 18, 16, 14, 12, 10, 4, 3, 2, 1 }; //мисля че интервалите са къси
        public int Row { get; set; }
        public int Col { get; set; }
        public int Points { get; set; }
        private int Symbol { get; set; }
        public int LastSymbol { get; set; }
        public bool isShoot { get; set; }
        public int level { get; set; }
        public int maxCol { get; set; }

        public Player(int row, int col, int level)
        {
            this.Col = col / 2;
            this.maxCol = col;
            this.Row = row;
            this.level = levels[level];
            this.Symbol = next.Next(1, 3); // струват ми се много числата за първо ниво 
        }
 
        private static Random next = new Random();

        public bool MovePlayer()
        {
            bool pressedSpace = this.Move();
            return pressedSpace;
        }

        public void Print()
        {
            Console.SetCursorPosition(0, this.Row);
            Console.Write(new string(' ', this.maxCol));
            Console.SetCursorPosition(this.Col, this.Row);
            Console.Write(this.Symbol);
        }

        public bool Move()
        {
            if (Console.KeyAvailable)
            {
                ConsoleKeyInfo inputKey = Console.ReadKey();
                if (inputKey.Key == ConsoleKey.LeftArrow)
                {
                    this.Col--;
                    if (this.Col < 0)
                    {
                        this.Col = 0;
                    }
                }
                else if (inputKey.Key == ConsoleKey.RightArrow)
                {
                    this.Col++;
                    if (this.Col > this.maxCol)
                    {
                        this.Col = this.maxCol;
                    }
                }
                if (inputKey.KeyChar == ' ')
                {
                    this.LastSymbol = this.Symbol;
                    this.Symbol = next.Next(1, 3);
                    this.isShoot = true;
                }
                return true;

            }
            return false;
        }

    }
}
